package com.dd.machine.base.activity;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.dd.machine.main.Interface.HardwareInterface;
import com.dd.machine.main.commons.AppManager;

/**
 * Created by xiao on 2016/4/18.
 */
public class BaseActivity extends Activity{

    protected Context applicationContext;
    protected Context context;
//    private SystemBarTintManager tintManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppManager.getAppManager().addActivity(this);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏
        applicationContext = getApplicationContext();
        context = this;

        initWindow();
    }



    @TargetApi(19)
    private void initWindow(){
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            tintManager = new SystemBarTintManager(this);
//            tintManager.setStatusBarTintColor(getResources().getColor(R.color.colorPrimary));
//            tintManager.setStatusBarTintEnabled(true);
//        }
    }

//    /**
//     * 获取用户的登陆状态
//     *
//     * @return true登陆  false没有登陆
//     */
//    public boolean getUserIsLogin() {
//        SharedPreferences sp = getSharedPreferences(UserInfoConstant.USERINFO_SHREDPREFERENCE, Context.MODE_PRIVATE);
//        String scope = sp.getString(UserInfoConstant.USRERINFO_SHRAREDPREFERCE_SCOPE, "");
//        if (!"login".equals(scope)) {
//            return false;
//        } else {
//            return true;
//        }
//    }
//
//    /**
//     * 跳转到登陆界面
//     */
//    public void toLogin() {
//        Intent it = new Intent();
//        it.setClass(this, LoginActivity.class);
//        it.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
//        startActivity(it);
//    }

    @Override
    protected void onResume() {
        super.onResume();
//        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
//        MobclickAgent.onPause(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppManager.getAppManager().finishActivity(this);
    }


}
